package com.itmuch.cloud.feign;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.itmuch.cloud.entity.User;

@FeignClient(name="microservice-provider-user")
public interface UserFeignClient {
    @RequestMapping(method = RequestMethod.GET, value = "/simple/{id}")
    public User findById(@PathVariable("id") Long id); //注意此处有两个坑：1.@GetMapping 注解不支持， 2.@PathVariable必须得设置value
    
    @RequestMapping(value="/user",method=RequestMethod.POST)
    public User postUser(@RequestBody User user);
    

    // 该请求不会成功，只要参数是复杂对象，即使指定了是GET方法，feign依然会以POST方法进行发送请求。可能是我没找到相应的注解或使用方法错误。
    // 如勘误，请@lilizhou2008  eacdy0000@126.com
    @RequestMapping(value = "/get-user", method = RequestMethod.GET)
    public User getUser(User user);
}
